var config = require("../../config");

Page({
  data:{},
  onLoad(e){
    
    let ShopId = e.ShopId, _this = this;
    wx.showLoading({
      title: '加载中...',
      mask:true
    });

    wx.request({    //获取门店详情
      method: "POST",
      url: config.service.ShopDetails,
      data: {
        store_id: ShopId
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success(res) {
        wx.hideLoading();
        console.log(res);
        if (res.data.code == 1) {
          _this.setData({
            ShopDetailsData:res.data.data,
            ImgHost: config.service.ImgHost
          });

        } else {
          wx.showToast({
            title: res.data.msg,
            icon: "loading",
            duration: 2000,
            mask: true
          });
        }

      }
    });
  },
  onShareAppMessage() {

  },
  
  /*导航*/ 
  Navigation(e){
    let td = this.data, latitude = parseFloat(e.currentTarget.dataset.lat), longitude = parseFloat(e.currentTarget.dataset.long);
    wx.openLocation({
      latitude: latitude,
      longitude: longitude,
      scale: 18,
      name: td.ShopDetailsData.store_name,
      address: td.ShopDetailsData.store_addr
    });
  },
  viewShopImg(){
    let imgArr = [this.data.ShopDetailsData.thumb];
   
    wx.previewImage({
      current: imgArr[0],     //当前图片地址
      urls: imgArr,               //所有要预览的图片的地址集合 数组形式
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  CallUp(){
    wx.makePhoneCall({
      phoneNumber: this.data.ShopDetailsData.store_contact,
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    });
  }
});